<?php
global $_W, $_GPC;

load()->func("tpl");
$article_sys = pdo_fetch("select * from" . tablename("ewei_shop_article_sys") . "where uniacid=:uniacid", array(
    ":uniacid" => $_W["uniacid"]
));

$article_sys["article_image"] = tomedia($article_sys["article_image"]);
if ($article_sys["article_temp"] == 0) {
    $limit = empty($article_sys["article_shownum"]) ? "10" : $article_sys["article_shownum"];
    $articles = pdo_fetchall("SELECT id,article_title,resp_img,article_date_v,article_readnum,article_readnum_v,article_rule_credit,article_rule_money,article_date,resp_desc FROM " . tablename("ewei_shop_article") . " WHERE article_state=1 and uniacid=:uniacid order by displayorder desc, article_date_v desc limit " . $limit, array(
        ":uniacid" => $_W["uniacid"]
    ));

    foreach ($articles as &$index){
        $readnum = intval($index["article_readnum"] + $index["article_readnum_v"]);
        $readnum = $readnum > 100000 ? "100000+" : $readnum;
        $index['readnum'] = $readnum;
    }
} elseif ($article_sys["article_temp"] == 1) {
    $limit = empty($article_sys["article_shownum"]) ? "7" : $article_sys["article_shownum"];
    $articles = pdo_fetchall("SELECT distinct article_date_v FROM " . tablename("ewei_shop_article") . " WHERE article_state=1 and uniacid=:uniacid order by article_date_v desc limit " . $limit, array(
        ":uniacid" => $_W["uniacid"]
    ), "article_date_v");
    foreach ($articles as &$a) {
        $a["articles"] = pdo_fetchall("SELECT id,article_title,article_date_v,resp_img,resp_desc,article_date_v ,resp_desc FROM " . tablename("ewei_shop_article") . " WHERE article_state=1 and uniacid=:uniacid and article_date_v=:article_date_v order by displayorder desc,article_date desc ", array(
            ":uniacid" => $_W["uniacid"],
            ":article_date_v" => $a["article_date_v"]
        ));
    }
    unset($a);
} elseif ($article_sys["article_temp"] == 2) {
    $categorys = pdo_fetchall("SELECT * FROM " . tablename("ewei_shop_article_category") . " WHERE uniacid=:uniacid ", array(
        ":uniacid" => $_W["uniacid"]
    ));
}
include $this->template("list");
?>